refactor: split RequestContext between server and client#1987
Conversation
RequestContext between server and client
Code ReviewI found 3 issues that need attention: Issue 1: Missing Migration DocumentationFile: src/mcp/shared/context.py This is a breaking change that requires migration documentation. According to CLAUDE.md:
This PR changes the type signatures of
Users with type annotations for tool/prompt/resource handlers or client callbacks will need to update their code:
Please add a section to Issue 2: Missing Docstring for Public APIFile: src/mcp/server/context.py (line 16) The new public API class According to CLAUDE.md:
Similar classes in the codebase have docstrings:
Please add a docstring to python-sdk/src/mcp/server/context.py Lines 15 to 21 in 3585b22 Issue 3: Incorrect Type SignatureFile: tests/client/test_list_roots_callback.py (line 36) The type signature The Current (incorrect): async def test_list_roots(context: Context[ServerSession], message: str):The problem: async def test_list_roots(context: Context[None], message: str):See the incorrect line here: python-sdk/tests/client/test_list_roots_callback.py Lines 35 to 37 in 3585b22 |
|
|
||
| async def default_elicitation_callback( | ||
| context: RequestContext[ClientSession, Any], # noqa: ARG001 | ||
| context: RequestContext[ClientSession], |
There was a problem hiding this comment.
Maybe we can have a ClientRequestContext.
There was a problem hiding this comment.
Yea true, would be nice to have both
Cute.